<?php
/**
 * Created by PhpStorm.
 * User: lili
 * Date: 19-4-22
 * Time: 下午1:28
 * 导出rating到csv
 */


//进队的处理




$dbms='mysql';     //数据库类型
$host='localhost'; //数据库主机名
$dbName='ll_newscms';    //使用的数据库
$user='root';      //数据库连接用户名
$pass='123456';          //对应的密码
$dsn="$dbms:host=$host;dbname=$dbName";

try {
    $dbh = new PDO($dsn, $user, $pass); //初始化一个PDO对象
    echo "连接成功<br/>";
    ini_set('memory_limit','100M');
    $list = $dbh->query(' SELECT ll_uid,ll_aid,ll_rating,ll_time from ll_rating ')->fetchAll();
    require_once '/home/lili/project/recommend/ll_newscms/extend/tool/Csv.php';
    $csv = new \tool\Csv();
    $csv_title = array('userId','AID','rating','timestamp');
    $csv->put_csv($list,$csv_title);

    $dbh = null;

} catch (PDOException $e) {
    die ("Error!: " . $e->getMessage() . "<br/>");
}


